import sys
sys.path.append("..")
from common.util import preprocess, create_co_matrix, cos_similarity

if __name__ == "__main__":
    text = 'You say goodbye and I say hello,I say one'
    corpus, word_to_id, id_to_word = preprocess(text)
    vocab_size = len(word_to_id)
    C = create_co_matrix(corpus, vocab_size)
    print(word_to_id)
    print(C)

    c0 = C[word_to_id['you']]  # you的单词向量
    c1 = C[word_to_id['i']]  # i的单词向量
    print("you和i的相似度: {}".format(cos_similarity(c0, c1)))
